package x.y.z;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@SpringBootApplication
public class App implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
    @Resource
    Info1 info1;
    @Resource
    Info2 info2;
    @Resource
    Info3 info3;

    @Override
    public void run(String... args) throws Exception {
        System.out.println(info1);
        System.out.println(info2);
        System.out.println(info3);
    }
}

@Data
@Component
class Info1{
    @Value("${info.name}")
    private String name;
    @Value("${info.path}")
    private String path;

}

@Data
@ConfigurationProperties(prefix="info")
@Component
class Info2{
    private String name;
    private String path;

}

@Data
@ConfigurationProperties(prefix="info")
@PropertySource("classpath:info.yml")
@Component
class Info3{
    private String name;
    private String path;

}